package com.xcity.game.combat.skill;

import java.lang.reflect.Constructor;

import com.xcity.game.combat.skill.impl.COMBAT_SKILL_100001;
import com.xcity.game.combat.skill.impl.COMBAT_SKILL_100002;
import com.xcity.game.combat.skill.impl.COMBAT_SKILL_100003;
import com.xcity.game.combat.skill.impl.COMBAT_SKILL_100004;
import com.xcity.game.combat.skill.impl.COMBAT_SKILL_100005;
import com.xcity.game.combat.skill.impl.COMBAT_SKILL_100006;
import com.xcity.game.combat.skill.impl.COMBAT_SKILL_100007;
import com.xcity.game.combat.skill.impl.COMBAT_SKILL_90083;
import com.xcity.game.combat.skill.impl.COMBAT_SKILL_90084;
import com.xcity.game.combat.skill.impl.COMBAT_SKILL_90085;
import com.xcity.game.combat.skill.impl.COMBAT_SKILL_90086;
import com.xcity.game.combat.skill.impl.COMBAT_SKILL_90087;
import com.xcity.game.combat.skill.impl.COMBAT_SKILL_90088;
import com.xcity.game.combat.skill.impl.COMBAT_SKILL_90089;
import com.xcity.game.combat.skill.impl.COMBAT_SKILL_90090;
import com.xcity.game.combat.skill.impl.COMBAT_SKILL_90091;
import com.xcity.game.combat.skill.impl.COMBAT_SKILL_90092;
import com.xcity.game.combat.skill.impl.COMBAT_SKILL_90093;
import com.xcity.game.combat.skill.impl.COMBAT_SKILL_90094;
import com.xcity.game.combat.skill.impl.COMBAT_SKILL_90095;
import com.xcity.game.combat.skill.impl.COMBAT_SKILL_90096;
import com.xcity.game.combat.skill.impl.COMBAT_SKILL_90097;
import com.xcity.game.combat.skill.impl.COMBAT_SKILL_90098;
import com.xcity.game.combat.skill.impl.COMBAT_SKILL_90099;
import com.xcity.game.combat.skill.impl.COMBAT_SKILL_90100;
import com.xcity.game.combat.skill.impl.COMBAT_SKILL_90101;
import com.xcity.game.combat.skill.impl.COMBAT_SKILL_90102;
import com.xcity.game.combat.skill.impl.COMBAT_SKILL_90103;
import com.xcity.game.combat.skill.impl.COMBAT_SKILL_90104;
import com.xcity.game.combat.skill.impl.COMBAT_SKILL_90105;
import com.xcity.game.combat.skill.impl.COMBAT_SKILL_90106;
import com.xcity.game.combat.skill.impl.COMBAT_SKILL_90107;
import com.xcity.game.combat.skill.impl.COMBAT_SKILL_90108;
import com.xcity.game.combat.skill.impl.COMBAT_SKILL_90109;
import com.xcity.game.combat.skill.impl.COMBAT_SKILL_90110;
import com.xcity.game.combat.skill.impl.COMBAT_SKILL_90111;
import com.xcity.game.combat.skill.impl.COMBAT_SKILL_90112;
import com.xcity.game.combat.skill.impl.COMBAT_SKILL_90113;
import com.xcity.game.combat.skill.impl.COMBAT_SKILL_90114;
import com.xcity.game.combat.skill.impl.COMBAT_SKILL_90115;
import com.xcity.game.combat.skill.impl.COMBAT_SKILL_90116;
import com.xcity.game.combat.skill.impl.COMBAT_SKILL_90117;
import com.xcity.game.combat.skill.impl.COMBAT_SKILL_90118;
import com.xcity.game.combat.skill.impl.COMBAT_SKILL_90119;
import com.xcity.game.combat.skill.impl.COMBAT_SKILL_90120;
import com.xcity.game.combat.skill.impl.COMBAT_SKILL_90121;
import com.xcity.game.combat.skill.impl.COMBAT_SKILL_90122;
import com.xcity.game.combat.skill.impl.COMBAT_SKILL_90123;
import com.xcity.game.combat.skill.impl.COMBAT_SKILL_90124;
import com.xcity.game.combat.skill.impl.COMBAT_SKILL_90125;
import com.xcity.game.combat.skill.impl.COMBAT_SKILL_90126;
import com.xcity.game.combat.skill.impl.COMBAT_SKILL_90127;
import com.xcity.game.combat.skill.impl.COMBAT_SKILL_90128;
import com.xcity.game.combat.skill.impl.COMBAT_SKILL_90129;
import com.xcity.game.combat.skill.impl.COMBAT_SKILL_90130;
import com.xcity.game.combat.skill.impl.COMBAT_SKILL_90131;
import com.xcity.game.combat.skill.impl.COMBAT_SKILL_90132;
import com.xcity.game.skill.Skill;
import com.xcity.game.skill.template.SkillTemplate;

import gnu.trove.map.TIntObjectMap;
import gnu.trove.map.hash.TIntObjectHashMap;

public enum CombatSkillFactory {

	S90083(COMBAT_SKILL_90083.class, 90083, 90041, 90042, 90043, 90044, 90045),
	S90084(COMBAT_SKILL_90084.class, 90084),
	S90085(COMBAT_SKILL_90085.class, 90085),
	S90086(COMBAT_SKILL_90086.class, 90086),
	S90087(COMBAT_SKILL_90087.class, 90087),
	S90088(COMBAT_SKILL_90088.class, 90088),
	S90089(COMBAT_SKILL_90089.class, 90089),
	S90090(COMBAT_SKILL_90090.class, 90090),
	S90091(COMBAT_SKILL_90091.class, 90091),
	S90092(COMBAT_SKILL_90092.class, 90092),
	S90093(COMBAT_SKILL_90093.class, 90093),
	S90094(COMBAT_SKILL_90094.class, 90094),
	S90095(COMBAT_SKILL_90095.class, 90095),
	S90096(COMBAT_SKILL_90096.class, 90096),
	S90097(COMBAT_SKILL_90097.class, 90097),
	S90098(COMBAT_SKILL_90098.class, 90098),
	S90099(COMBAT_SKILL_90099.class, 90099),
	S90100(COMBAT_SKILL_90100.class, 90100),
	S90101(COMBAT_SKILL_90101.class, 90101),
	S90102(COMBAT_SKILL_90102.class, 90102),
	S90103(COMBAT_SKILL_90103.class, 90103),
	S90104(COMBAT_SKILL_90104.class, 90104),
	S90105(COMBAT_SKILL_90105.class, 90105),
	S90106(COMBAT_SKILL_90106.class, 90106),
	S90107(COMBAT_SKILL_90107.class, 90107),
	S90108(COMBAT_SKILL_90108.class, 90108),
	S90109(COMBAT_SKILL_90109.class, 90109),
	S90110(COMBAT_SKILL_90110.class, 90110),
	S90111(COMBAT_SKILL_90111.class, 90111),
	S90112(COMBAT_SKILL_90112.class, 90112),
	S90113(COMBAT_SKILL_90113.class, 90113),
	S90114(COMBAT_SKILL_90114.class, 90114),
	S90115(COMBAT_SKILL_90115.class, 90115),
	S90116(COMBAT_SKILL_90116.class, 90116),
	S90117(COMBAT_SKILL_90117.class, 90117),
	S90118(COMBAT_SKILL_90118.class, 90118),
	S90119(COMBAT_SKILL_90119.class, 90119),
	S90120(COMBAT_SKILL_90120.class, 90120),
	S90121(COMBAT_SKILL_90121.class, 90121),
	S90122(COMBAT_SKILL_90122.class, 90122),
	S90123(COMBAT_SKILL_90123.class, 90123),
	S90124(COMBAT_SKILL_90124.class, 90124),
	S90125(COMBAT_SKILL_90125.class, 90125),
	S90126(COMBAT_SKILL_90126.class, 90126),
	S90127(COMBAT_SKILL_90127.class, 90127),
	S90128(COMBAT_SKILL_90128.class, 90128),
	S90129(COMBAT_SKILL_90129.class, 90129),
	S90130(COMBAT_SKILL_90130.class, 90130),
	S90131(COMBAT_SKILL_90131.class, 90131),
	S90132(COMBAT_SKILL_90132.class, 90132),
	S100001(COMBAT_SKILL_100001.class, 100001),
	S100002(COMBAT_SKILL_100002.class, 100002),
	S100003(COMBAT_SKILL_100003.class, 100003),
	S100004(COMBAT_SKILL_100004.class, 100004),
	S100005(COMBAT_SKILL_100005.class, 100005),
	S100006(COMBAT_SKILL_100006.class, 100006),
	S100007(COMBAT_SKILL_100007.class, 100007),

	;

	private final Class<? extends CombatSkill> clazz;
	private final int[] ids;
	
	private static TIntObjectMap<Constructor<? extends CombatSkill>> constructors = new TIntObjectHashMap<>(32);
	
	static {
		CombatSkillFactory[] vals = values();
		for (CombatSkillFactory val : vals) {
			try {
				Constructor<? extends CombatSkill> con = val.clazz.getConstructor(Skill.class);
				for (int id : val.ids) {
					constructors.put(id, con);
				}
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	}
	
	CombatSkillFactory(Class<? extends CombatSkill> clazz, int... ids) {
		this.ids = ids;
		this.clazz = clazz;
	}
	
	public static boolean contains(SkillTemplate template) {
		return constructors.containsKey(template.getId());
	}

	public static CombatSkill create(Skill skill) {
		try {
			Constructor<? extends CombatSkill> con = constructors.get(skill.getId());
			if (con != null) {
				return con.newInstance(skill);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}
}
